﻿using System;

namespace ProblemsSet
{
    public class Problem_47 : BaseProblem
    {
        public override object GetResult()
        {
            const int mx = 4;

            var i = 9;
            while (true)
            {
                i++;
                var ex = true;
                for (var j = 0; j < mx; j++)
                {
                    var q = MathLogic.GetPrimeFactors(i + j);
                    if (q.Count == mx) continue;
                    ex = false;
                    break;
                }
                if (ex) return i;
            }
            return -1;
        }

        public override string Problem
        {
            get
            {
                return @"The first two consecutive numbers to have two distinct prime factors are:

14 = 2  7
15 = 3  5

The first three consecutive numbers to have three distinct prime factors are:

644 = 2²  7  23
645 = 3  5  43
646 = 2  17  19.

Find the first four consecutive integers to have four distinct primes factors. What is the first of these numbers?";
            }
        }

        public override bool IsSolved
        {
            get
            {
                return true;
            }
        }

        public override object Answer
        {
            get
            {
                return 134043;
            }
        }
    }
}
